package com.hyperfix.simulator.senor;

import com.hyperfix.models.simulator.pojos.params.DiffPressure;
import com.hyperfix.utils.common.RandomUtil;

/**
 * @author JiangChunYu
 * 2024/3/15
 */
public class DiffPressureSenor implements InstantParamSenor {
    @Override
    public byte[] nextData() {
        int v = RandomUtil.nextRangeInt(DiffPressure.getMaxValue(), DiffPressure.getMinValue());
        byte symbol = 0;
        if (v < 0) symbol = 1;
        byte[] data = new byte[2];
        data[0] = (byte) ((v >>> 7) | data[0]);
        data[1] = (byte) ((((byte) v) << 1) | symbol);
        return data;
    }
}
